<template>
	<view class="couponSelect">
		<view class="couponItem" v-for="(item,index) in listCoupon" :key="index">
				<view class="coupon">
					<view class="coupon-right">
						<view class="right-block">
							<view class="block-price">
								<block v-if="item.couponType == '0'">
									-<Money :priceValue="item.couponVal" :activeClass="['money-price','money-price-white']"></Money>
								</block>
								<block v-else-if="item.couponType == '1'">
									{{item.couponVal}}折
								</block>
							</view>
							<view class="block-scope oneline-hide">
								{{item.limitDesc}}
							</view>
						</view>
					</view>
					<view class="coupon-left">
						<view class="f-w">
							<!-- <block v-if="item.couponScope == '1'">
								{{item.name}}
							</block>
							<block v-else-if="item.couponScope == '2'">
								<view class="flex">
									{{item.tenantName}}
								</view>
							</block> -->
							{{item.couponName}}
						</view>
						<view class="f-24 f-tip py-1">
							{{item.scopeDesc}}
						</view>
						<view class="f-24 f-tip p-a bottom-0">
							{{item.expireDesc}}
						</view>
					</view>
					<view class="coupon-check" @click="selectCoupon(item)">
						<Check :isCheck="isCheck(item.id)"></Check>
					</view>
				</view>
		</view>
	</view>
	
</template>

<script>
	import Constants from '@/constants';
	import Money from '@/pages/components/money/money.vue';
	import List from '@/pages/components/list/list.vue';
	import Check from '@/components/sl-button/check.vue';
	//优惠券组件（选择优惠券）
	//@group 业务组件
	export default {
		//
		name: 'couponSelect',
		//
		mixins: [Constants],
		//
		components: {
			List,
			Money,
			Check
		},
		//
		props: {
			//被选中的优惠券
			selectedCouponId: {
				default: 'hello'
			},
			//优惠券集合
			listCoupon: {
				type: Array,
				default () {
					return [];
				}
			}
		},
		methods: {
			//当前优惠券是否被选中
			isCheck(couponId) {
				return couponId === this.selectedCouponId ? 'checked' : 'check';
			},
			//选中优惠券
			selectCoupon(item) {
				//
				this.$emit('update:selectedCouponId', item.id)
				this.$emit('selectCoupon:result', item);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.couponSelect{
		display: flex;
		flex-direction: column;
		.couponItem{
			background: $uni-bg-color;
			padding: $xj-standard-padding;
			border-radius: $xj-standard-border-radius;
			margin: 20rpx;
		}
	}
	.coupon {
		font-size: $uni-font-size-base;
		height: 188rpx;
		position: relative;
		display: flex;
		justify-content: space-between;
	
		.coupon-left {
			font-size: $uni-font-size-lg;
			flex:1;
			padding: 16rpx 38rpx;
	
			.profile-tenant {
				position: relative;
				width: 52rpx;
				height: 52rpx;
				margin-right: 16rpx;
			}
		}
	
		.coupon-right {
			display: flex;
			align-items: center;
	
			.right-block {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				width: 115px;
				height: 92px;
				border-radius: 8px;
				background: linear-gradient(135deg, #FFC28A 0.01%, #FF2323 100%);
				padding: 10rpx;
				.block-price {
					color: $uni-text-color-inverse;
					text-align: center;
					font-size: 40rpx;
					font-weight: 700;
					line-height: 44rpx;
					margin-top: 8rpx;
					display: flex;
				}
	
				.block-scope {
					color: $uni-text-color-inverse;
					text-align: center;
					font-size: 20rpx;
					line-height: 44rpx;
				}
	
				.block-receive {
					display: flex;
					padding: 4rpx 16rpx;
					justify-content: center;
					align-items: center;
					border-radius: 76rpx;
					border: 0.5px solid $uni-text-color-inverse;
					color: $uni-text-color-inverse;
					font-weight: 500;
					width: 140rpx;
				}
			}
		}
		.coupon-check{
			display: flex;
			flex-basis: 10%;
			align-items: center;
		}
	}
</style>